import 'package:base_flutter/base_flutter.dart';
import 'package:flutter/src/widgets/framework.dart';
import 'package:ls_work/net/post_request.dart';

import '../../net/response/bed/bed_record_data.dart';

class BedRecordViewModel extends BaseListViewModel<BedRecordData>{
  final String bedId;
  BedRecordViewModel(BuildContext context,this.bedId) : super(context);

  @override
  Future<List<BedRecordData>> requestListData() async {
    var data = await PostRequest.bedRecord(bedId, page, pageLength);
    if('0'==data['code'].toString()){
      var list = ((data['data']['rows'] as List?)??[]).map((e) => BedRecordData.fromJson(e)).toList();
      return list;
    }else{
      throw data['msg'];
    }
  }

  @override
  void onCreated() {
    super.onCreated();
    requestRefresh();
  }

}